<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>地图详情</title>
    <link rel="stylesheet" type="text/css" href="../lib/laydate.css"/>
    <link rel="stylesheet" href="../../lib/layui/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../css/base.css"/>
    <script type="text/javascript" src="../js/news/jquery-1.9.1.js"></script>
    <script src="../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script language=javascript src='http://api.map.baidu.com/api?v=2.0&ak=7HSdUGqKaz5U0ph0LIQ2Qd4rFmFZA2kY'></script>
    <script src="../lib/layer/layer.js?20201106"></script>
    <style>
        .bx{
            width: 100%;
            height: 100%;
        }
        ul li{
            width: 95%;
            height: 100px;
            line-height: 100px;
            margin:10px 10px;
            border-bottom: 1px solid #ccc;
            overflow: hidden; /*超出的隐藏*/
            white-space: nowrap;
            text-overflow:ellipsis; /*超出的设置为省略号*/
        }
        ul li span,b{
            font-size: 30px;
        }
        ul li span{
            font-size: 30px;
            margin-left: 10px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>

</head>

<body>
<div class="bx">
    <%--<div class="cont" style="display: none">--%>
    <%----%>
    <%--</div>--%>
    <div>
        <div id="map" style="width:100%;height:100%"></div>
    </div>
</div>

<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("map");
    map.enableScrollWheelZoom();
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 15);

    $(function(){
        $.ajax({
            url:'/construingunit/selectAllConstruingUnit2',
            type:'get',
            dataType:'json',
            success:function(res){
                var obj = res.obj
                var address=[];
                for(var i=0;i<obj.length;i++){
                    var data = {lat:obj[i].longitude,id:obj[i].cuId}
                    address.push(data)
                }
                getPoint(address)
            }
        })
    })

    function  getPoint(address) {
        var json =[];
        var id
        for(var i=0;i<address.length;i++){
            json.push(address[i])
        }
        var pointArray = new Array();
        for(var i=0;i<json.length;i++){
             console.log(json[i])
            var marker = new BMap.Marker(new BMap.Point(json[i].lat.split(',')[0], json[i].lat.split(',')[1])); // 创建点
            map.addOverlay(marker);    //增加点
            pointArray[i] = new BMap.Point(json[i].lat.split(',')[0], json[i].lat.split(',')[1],json[i].id);
            marker.addEventListener("click",attribute);
        }
        //让所有点在视野范围内
        map.setViewport(pointArray);
    }
    function attribute(e){
        var p = e.target;
        var pict = p.getPosition().lng + "," + p.getPosition().lat
        $.ajax({
            url:'/construingunit/selectAllConstruingUnit2',
            type:'get',
            dataType:'json',
            success:function(res){
                var datas = res.obj
                for(var i=0;i<datas.length;i++){
                    var longitude = datas[i].longitude
                    if(longitude == pict){
                        $.ajax({
                            url:'/construingunit/selectAllConstruingUnit2',
                            type:'get',
                            dataType:'json',
                            data:{cuId:datas[i].cuId},
                            success:function(res){
                                var str = res.obj[0]
                                layer.open({
                                    type: 1,
                                    title: "<span style='font-size:20px'>详情</span>",
                                    shade: 0.5,
                                    maxmin: true, //开启最大化最小化按钮
                                    area: ['70%', '80%'],
                                    content:' <ul>\n' +
                                        '        <li>\n' +
                                        '            <b>建设单位名称：</b>\n' +
                                        '            <span>'+str.cuName+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>建设单位社会信用代码：</b>\n' +
                                        '            <span>'+str.cuCode+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>工程名称：</b>\n' +
                                        '            <span>'+str.projectName+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>建设地址：</b>\n' +
                                        '            <span>'+str.constructionAddress+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>合同金额：</b>\n' +
                                        '            <span>'+str.amount+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>开工日期：</b>\n' +
                                        '            <span>'+str.commencementDate+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>竣工日期：</b>\n' +
                                        '            <span>'+str.completionDate+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>施工单位名称：</b>\n' +
                                        '            <span>'+str.constructionUnitName+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>建设单位社会信用代码：</b>\n' +
                                        '            <span>'+str.constructionUnitCode+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>施工单位属地：</b>\n' +
                                        '            <span>'+str.constructionUnitPossession+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>是否在区内开设分公司：</b>\n' +
                                        '            <span>'+str.branchOffice+'</span>\n' +
                                        '        </li>\n' +
                                        '        <li>\n' +
                                        '            <b>备注：</b>\n' +
                                        '            <span>'+str.remark+'</span>\n' +
                                        '        </li>\n' +
                                        '    </ul>'
                                })
                            }
                        })
                    }
                }
            }
        })
    }
</script>
</body>
</html>
